package com.spica.platform.base.exception.errorcode;

import com.spica.platform.common.utils.StringUtil;

import java.util.Arrays;

public enum ValidationRtnCodEnum implements IErrorCode {
    UN_KNOWN_VALIDATE_ERROR("BASE_VALIDATE_00000", "未知校验异常"),
    ;
    private String rtnCod;
    private String rtnMsg;

    ValidationRtnCodEnum(String rtnCod, String rtnMsg) {
        this.rtnCod = rtnCod;
        this.rtnMsg = rtnMsg;
    };
    @Override
    public String getRtnMessage() {
        return rtnMsg;
    }

    @Override
    public String getRtnCode() {
        return rtnCod;
    }

    @Override
    public IErrorCode getInstanceByErrorCode(String rtnCod) {
        return Arrays.stream(ValidationRtnCodEnum.values())
                .filter(validationRtnCodEnum -> StringUtil.equals(validationRtnCodEnum.rtnCod, rtnCod))
                .findFirst().orElse(ValidationRtnCodEnum.UN_KNOWN_VALIDATE_ERROR);
    }
}
